{% macro default(url, message, id, icon, class) %}
    <a class="btn {% if class is not empty %}{{ class }}{% endif %}" {% if id is not null %} id="{{ id }}"{% endif %} href="{{ url }}" {{ sylius_test_html_attribute('button', id|default(message)) }}>
        {% if icon is not empty %}
            {{ ux_icon(icon, { class: 'icon icon-sm flex-shrink-0' }) }}
        {% endif %}
        {% if message is not empty %}
            {{ message|trans }}
        {% endif %}
    </a>
{% endmacro %}

{% macro submit(message, id, icon, class, disabled = false) %}
    <button type="submit" class="btn {% if class is not empty %}{{ class }}{% endif %}" {% if id is not null %}id="{{ id }}"{% endif %} {{ sylius_test_html_attribute('button', id|default(message)) }} {% if disabled %}disabled="disabled"{% endif %}>
        {% if icon is not empty %}
            {{ ux_icon(icon, { class: 'icon icon-sm' }) }}
        {% endif %}
        {% if message is not empty %}
            {{ message|trans }}
        {% endif %}
    </button>
{% endmacro %}

{% macro transparent(url, message, id, icon, class, attributes = {}) %}
    <a
        href="{{ url }}"
        class="link-reset{% if class is not empty %} {{ class }}{% endif %}"
        {% if id is not null %} id="{{ id }}"{% endif %}
        {{ sylius_test_html_attribute('button', id|default(message)) }}
        {% for name, value in attributes %}
            {{ name }}="{{ value }}"
        {% endfor %}
    >
        {% if icon is not empty %}
            {{ ux_icon(icon, { class: 'icon icon-sm' }) }}
        {% endif %}
        {% if message is not empty %}
            {{ message|trans }}
        {% endif %}
    </a>
{% endmacro %}

{% macro primary(url, message, id, icon) %}
    {{ _self.default(url, message, id, icon, 'btn-primary') }}
{% endmacro %}

{% macro secondary(url, message, id, icon) %}
    {{ _self.default(url, message, id, icon, 'btn-secondary') }}
{% endmacro %}

{% macro link(url, message, id, icon) %}
    {{ _self.default(url, message, id, icon, 'btn-link') }}
{% endmacro %}

{% macro delete(url, message, labeled = true, resourceId = null) %}
    <form action="{{ url }}" method="post">
        <input type="hidden" name="_method" value="DELETE">
        <button class="btn btn-sm btn-icon btn-outline-danger w-full" type="submit" data-requires-confirmation {{ sylius_test_html_attribute('button', 'delete') }}>
            {{ ux_icon('tabler:trash', {'class': 'icon icon-xs'})}} {{ ((message is empty and labeled) ? 'sylius.ui.delete' : message)|trans }}
        </button>
        <input type="hidden" name="_csrf_token" value="{{ csrf_token(resourceId) }}" />
    </form>
{% endmacro %}
